package cn.maihe.elg.operation.model.enums;

import java.util.Arrays;

/**
 * @Description
 * @Author Alan
 * @Date 2025/01/26
 */
public enum InstitutionOrgCodeEnum {

    DXDB("DXDB", "得兴担保"),
    XYDB("XYDB", "仙游担保"),

    ;

    /**
     * 中心编码 固定5位
     */
    private String orgCode;
    /**
     * 中心名称
     */
    private String orgName;

    InstitutionOrgCodeEnum(String orgCode, String centerName) {
        this.orgCode = orgCode;
        this.orgName = centerName;
    }

    public String getOrgCode() {
        return orgCode;
    }

    public String getOrgName() {
        return orgName;
    }

    public static InstitutionOrgCodeEnum resolve(String orgCode) {
        return Arrays.stream(values()).filter(o -> o.getOrgCode().equals(orgCode)).findFirst().orElseThrow(() -> new RuntimeException("查无此出函机构编码[" + orgCode + "]记录"));
    }

    public static InstitutionOrgCodeEnum resolveBy(String orgCode) {
        return Arrays.stream(values()).filter(o -> o.getOrgCode().equals(orgCode)).findFirst().orElseThrow(() -> new RuntimeException("查无此出函机构编码[" + orgCode + "]记录"));
    }


    @Override
    public String toString() {
        return String.format("%s:%s", orgCode, orgName);
    }
}
